let express = require('express');
let router = express.Router();
/* GET home page. */


/**
 * 用户注册
 */
router.all('/addRole', function (req, res, next) {
    global['bean'].RoleService.addRoleEntity(req.args).then(data => {
        res.json(res.wrap(20000, '添加角色成功!', data));
    }).catch(e => {
        next(e);
    });
});
/**
 * 删除角色
 */
router.all('/removeRole', function (req, res, next) {
    global['bean'].RoleService.removeRoleEntity(req.args).then(data => {
        res.json(res.wrap(20000, '删除角色成功!', data))
    }).catch(e => {
        next(e);
    });
});


/**
 * 更新角色
 */
router.all('/updateRole', function (req, res, next) {
    global['bean'].RoleService.updateRoleEntity(req.args).then(data => {
        res.json(res.wrap(20000, '修改角色成功!', data))
    }).catch(e => {
        next(e);
    });
});

/**
 * 获取角色
 */
router.all('/listRoles', function (req, res, next) {

    global['bean'].RoleService.listRoleEntities(req.args.start || 0, req.args.size || 10,req.args.keyWord).then(data => {
            res.json(res.wrap(20000, '查询角色', data))
    }).catch(e=>{
        next(e)
    })
});

module.exports = router;
